//
//  UIBarButtonItem+Extension.swift
//  MVVM微博
//
//  Created by AppleDev on 2017/7/16.
//  Copyright © 2017年 AppleDev. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    
    convenience init(title:String,fontSize:CGFloat = 16,target:AnyObject? , action:Selector,isBack:Bool = false) {
        
        
        
        let btn :UIButton = UIButton.cz_textButton(title, fontSize: fontSize, normalColor: #colorLiteral(red: 0.501960814, green: 0.501960814, blue: 0.501960814, alpha: 1), highlightedColor: #colorLiteral(red: 0.9372549057, green: 0.3490196168, blue: 0.1921568662, alpha: 1))
        btn.addTarget(target, action: action, for: .touchUpInside)
        if isBack {
         
            let imageName = "navigationbar_back_withtext"
            
            btn.setImage(UIImage(named: imageName), for: .normal)
            
            btn.setImage(UIImage(named: imageName + "_highlighted"), for: .highlighted)

            btn.sizeToFit()
        }
        self.init(customView: btn)
        
        
    }
    
}
